<!DOCTYPE html>
<html>
	<head>
		<link rel="stylesheet"  href="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.css" />
		<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
		<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script>
		<script type="text/javascript" src="jquery.json-2.3.min"></script>
		<script type="text/javascript">
		function init()
		{
			var user_id = "aglub19hcHBfaWRyCwsSBXVzZXJzGAEM";
			window.sessionStorage.user_id = user_id;
			var param = "user_id="+user_id;
			/*if(window.localStorage.getItem(user_id)!=null && 
				localStorage.getItem(user_id).last_update_id!=null && 
				localStorage.getItem(user_id).last_update_id!="")
			{
				param += "&last_update_id="+window.localStorage.getItem(user_id).last_update_id;
			}*/
			$.getJSON("get/user/updates?"+param,
			{
				format: "json"
			},
			function(data)
			{
				if(window.localStorage.getItem(user_id+"_updates")!=null)
					window.localStorage.removeItem(user_id+"_updates");
				if(window.localStorage.getItem(user_id+"_last_update_id")!=null)
					window.localStorage.removeItem(user_id+"_last_update_id");
				var temp = [];
				if(window.localStorage.getItem(user_id+"_updates")!=null)
				{
					var temp = JSON.parse(window.localStorage.getItem(user_id+"_updates"));
				}
				temp = temp.concat(data.results);
				window.localStorage.setItem(user_id+"_updates",JSON.stringify(temp));
				//alert(window.localStorage.getItem(user_id+"_updates"));
				window.localStorage.setItem(user_id+"_last_update_id",data.last_update_id);
				//alert(window.localStorage.getItem(user_id+"_last_update_id"));
				//alert(0);
				window.location = "application.jsp";
			});
		}
		</script>
	</head>
	<body onload="init()">
	</body>
</html>